﻿<Page
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
	  x:Class="MovieRental_Presentation.Statistics" 
      d:DesignWidth="1024" d:DesignHeight="600"
      mc:Ignorable="d"
      WindowTitle="Movie Rental"
	  MinWidth="900"
	  MinHeight="500" 
      ShowsNavigationUI="False" Name="statisticsPage" Loaded="statisticsPage_Loaded">

	<Grid x:Name="LayoutRoot" Background="{StaticResource backgroundBrush}">
		<Grid.ColumnDefinitions>
			<ColumnDefinition/>
			<ColumnDefinition Width="250"/>
		</Grid.ColumnDefinitions>
		<Border BorderThickness="{StaticResource borderThickness}" Padding="{StaticResource borderPadding}" Margin="8" CornerRadius="{StaticResource borderCornerRadius}" BorderBrush="{StaticResource borderBrush}" Grid.Column="1">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="210"/>
					<RowDefinition/>
				</Grid.RowDefinitions>
				<StackPanel Grid.Row="0">
					<Label Content="Menu" HorizontalAlignment="Center" Style="{StaticResource MenuLabelStyle}"/>
					<Button x:Name="dashboardButton" Content="Dashboard" Height="40" Margin="0,8" Template="{StaticResource MenuButtonTemplate}" Click="dashboardButton_Click"/>
					<Button x:Name="customersButton" Content="Customers" Height="40" Margin="0,8" Template="{StaticResource MenuButtonTemplate}" Click="customersButton_Click"/>
					<Button x:Name="moviesButton" Content="Movies" Height="40" Margin="0,8" Template="{StaticResource MenuButtonTemplate}" Click="moviesButton_Click"/>
				</StackPanel>
				<Frame Content="" Grid.Row="1" Margin="0" Source="/MovieRental.Presentation;component/Cart.xaml" NavigationUIVisibility="Hidden"/>
			</Grid>
		</Border>
		<Grid Margin="8">
			<Grid.RowDefinitions>
				<RowDefinition Height="*"/>
				<RowDefinition Height="*"/>
			</Grid.RowDefinitions>
			<Border BorderBrush="{StaticResource borderBrush}" BorderThickness="{StaticResource borderThickness}" Margin="0" Padding="{StaticResource borderPadding}" CornerRadius="{StaticResource borderCornerRadius}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto"/>
						<RowDefinition Height="Auto"/>
						<RowDefinition/>
					</Grid.RowDefinitions>
					<Label Content="Statistics" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource MenuLabelStyle}"/>
					<Grid Grid.Row="1">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="*"/>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						<TextBlock Grid.Column="0" Text="Start Date" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource inputBoxBrush}" VerticalAlignment="Center"/>
						<DatePicker Grid.Column="1" Margin="8,0,0,0" FontSize="{StaticResource infoTextSize}" SelectedDate="{Binding StartDate, Mode=TwoWay}"/>
						<TextBlock Grid.Column="2" Text="Income" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource inputBoxBrush}"/>
						<TextBlock Grid.Column="3" Text="End Date" VerticalAlignment="Center" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource inputBoxBrush}"/>
                        <DatePicker Grid.Column="4" FontSize="{StaticResource infoTextSize}" VerticalAlignment="Center" Margin="8,0,0,0" SelectedDate="{Binding EndDate, Mode=TwoWay}"/>
					</Grid>
					<Canvas Margin="0,8" Grid.Row="2" Name="chartCanvas" />
					<Button x:Name="backButton" Content="Back" HorizontalAlignment="Left" Margin="8,0,0,0" Width="60" Click="backButton_Click" VerticalAlignment="Center"/>
					
				</Grid>
			</Border>
			<Grid Margin="0,8,0,0" Grid.Row="1">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*"/>
					<ColumnDefinition Width="*"/>
				</Grid.ColumnDefinitions>
				<Border BorderBrush="{StaticResource borderBrush}" BorderThickness="{StaticResource borderThickness}" CornerRadius="{StaticResource borderCornerRadius}" Margin="0,0,4,0">
					<Grid Margin="8,0,8,8">
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="*"/>
							<RowDefinition Height="Auto"/>
							<RowDefinition Height="Auto"/>
						</Grid.RowDefinitions>
						<Label Content="Personal Discount Rules" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource MenuLabelStyle}"/>
						<DataGrid Margin="0,0,0,8" Grid.Row="1" ItemsSource="{Binding PersonalDiscounts}" IsReadOnly="True" AutoGenerateColumns="False" Name="personalDiscountsDataGrid">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Spent Money Condition" Binding="{Binding Path=SpentMoneyCondition, StringFormat=\{0:c\}}" Width="*" />
                                <DataGridTextColumn Header="Discount Value" Binding="{Binding Path=Value, StringFormat=\{0\}%}" Width="*"/>
                            </DataGrid.Columns>
                        </DataGrid>
                        <Grid Margin="0,0,0,8" Grid.Row="2" Visibility="{Binding ElementName=personalDiscountGrid, Path=Visibility, Converter={StaticResource visibilityReverseConverter}}">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*"/>
								<ColumnDefinition Width="*"/>
							</Grid.ColumnDefinitions>
							<Button Grid.Column="0" Content="Add" Margin="0,0,4,0" Name="addPersonalDiscountButton" Click="addPersonalDiscountButton_Click" />
							<Button Grid.Column="1" Content="Delete" Margin="4,0,0,0" Name="deletePersonalDiscountButton" Click="deletePersonalDiscountButton_Click" />
						</Grid>
						<Grid Grid.Row="3" Visibility="Collapsed" Name="personalDiscountGrid">
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
							</Grid.RowDefinitions>
							<TextBlock Grid.Row="0" Text="New discount rule" HorizontalAlignment="Center" Foreground="{StaticResource borderBrush}" FontSize="{StaticResource infoTextSize}"/>
							<Grid Grid.Row="1">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto"/>
									<RowDefinition Height="Auto"/>
								</Grid.RowDefinitions>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="Auto"/>
									<ColumnDefinition Width="2*"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<TextBlock Grid.Row="0" Grid.Column="0" Text="Spent Money" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource inputBoxBrush}" Margin="0,8,0,0"/>
                                <TextBox Text="{Binding Mode=TwoWay, Path=SpentMoney, UpdateSourceTrigger=LostFocus}" Grid.ColumnSpan="2" Grid.Column="1" VerticalAlignment="Center" Margin="8,8,0,0" Background="{StaticResource backgroundBrush}" Foreground="{StaticResource inputBoxBrush}" BorderBrush="{StaticResource borderBrush}"/>
								<TextBlock Grid.Row="1" Grid.Column="0" Text="Value" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource inputBoxBrush}" Margin="0,8,0,0"/>
								<Slider Minimum="{Binding PersonalDiscountBound.Lower}" Maximum="{Binding PersonalDiscountBound.Upper}" Grid.Row="1" Grid.Column="1" BorderThickness="8,0,0,0" Margin="0,8,0,0" Name="personalDiscountSlider" TickFrequency="0.5" IsSnapToTickEnabled="True" />
								<TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding ElementName=personalDiscountSlider, Path=Value, StringFormat=\{0\}%}" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource inputBoxBrush}" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
							</Grid>
							<Grid Grid.Row="2" Margin="0,8,0,0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="*"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<Button Grid.Column="0" Content="Apply" Margin="0,0,4,0" Name="applyPersonalDiscountButton" Click="applyPersonalDiscountButton_Click" />
								<Button Grid.Column="1" Content="Cancel" Margin="4,0,0,0" Name="cancelPersonalDiscountButton" Click="cancelPersonalDiscountButton_Click" />
							</Grid>
						</Grid>
					</Grid>
				</Border>
				<Border BorderBrush="{StaticResource borderBrush}" BorderThickness="{StaticResource borderThickness}" CornerRadius="{StaticResource borderCornerRadius}" Margin="4,0,0,0" Grid.Column="1">
					<Grid Margin="8,0,8,8">
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="*"/>
							<RowDefinition Height="Auto"/>
							<RowDefinition Height="Auto"/>
						</Grid.RowDefinitions>
						<Label Content="Cart Discount Rules" HorizontalAlignment="Center" Style="{StaticResource MenuLabelStyle}"/>
                        <DataGrid Grid.Row="1" AutoGenerateColumns="False" ItemsSource="{Binding CartDiscounts}" IsReadOnly="True" IsEnabled="True" Name="cartDiscountsDataGrid">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Quantity Condition" Binding="{Binding QuantityCondition}" Width="*" />
                                <DataGridTextColumn Header="Discount Value" Binding="{Binding Path=Value, StringFormat=\{0\}%}" Width="*"  />
                            </DataGrid.Columns>
                        </DataGrid>
                        <Grid Margin="0,8" Grid.Row="2" Visibility="{Binding ElementName=cartDiscountGrid, Path=Visibility, Converter={StaticResource visibilityReverseConverter}}">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*"/>
								<ColumnDefinition Width="*"/>
							</Grid.ColumnDefinitions>
							<Button Grid.Column="0" Content="Add" Margin="0,0,4,0" Name="addCartDiscountButton" Click="addCartDiscountButton_Click" />
							<Button Grid.Column="1" Content="Delete" Margin="4,0,0,0" Name="deleteCartDiscountButton" Click="deleteCartDiscountButton_Click" />
						</Grid>
						<Grid Grid.Row="3" Visibility="Collapsed" Name="cartDiscountGrid" Margin="0,8,0,0">
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="Auto"/>
							</Grid.RowDefinitions>
							<TextBlock Grid.Row="0" Text="New discount rule" HorizontalAlignment="Center" Foreground="{StaticResource borderBrush}" FontSize="{StaticResource infoTextSize}"/>
							<Grid Grid.Row="1">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto"/>
									<RowDefinition Height="Auto"/>
								</Grid.RowDefinitions>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="Auto"/>
									<ColumnDefinition Width="2*"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<TextBlock Grid.Row="0" Grid.Column="0" Text="Quantity" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource inputBoxBrush}" Margin="0,8,0,0"/>
								<TextBox Text="{Binding Mode=TwoWay, Path=Quantity, UpdateSourceTrigger=LostFocus}" Grid.ColumnSpan="2" Grid.Column="1" VerticalAlignment="Center" Margin="8,8,0,0" Background="{StaticResource backgroundBrush}" Foreground="{StaticResource inputBoxBrush}" BorderBrush="{StaticResource borderBrush}"/>
								<TextBlock Grid.Row="1" Grid.Column="0" Text="Value" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource inputBoxBrush}" Margin="0,8,0,0"/>
								<Slider  Minimum="{Binding CartDiscountBound.Lower}" Maximum="{Binding CartDiscountBound.Upper}" Grid.Row="1" Grid.Column="1" BorderThickness="8,0,0,0" Margin="0,8,0,0" Name="cartDiscountSlider" IsSnapToTickEnabled="True" TickFrequency="0.5" />
								<TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding ElementName=cartDiscountSlider, Path=Value, StringFormat=\{0\}%}" FontSize="{StaticResource infoTextSize}" Foreground="{StaticResource inputBoxBrush}" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
							</Grid>
							<Grid Grid.Row="2" Margin="0,8,0,0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="*"/>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<Button Grid.Column="0" Content="Apply" Margin="0,0,4,0" Name="applyCartDiscountButton" Click="applyCartDiscountButton_Click" />
								<Button Grid.Column="1" Content="Cancel" Margin="4,0,0,0" Name="cancelCartDiscountButton" Click="cancelCartDiscountButton_Click" />
							</Grid>
						</Grid>
					</Grid>
				</Border>
				
			</Grid>
		</Grid>
	</Grid>
</Page>